<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ccDetail="http://xmlns.jcp.org/jsf/composite/compositions/candidateDetail">

    <body>

        <ui:composition template="/WEB-INF/templates/newMainCompanyTemplate.xhtml">

            <ui:define name="companyContent">
                <h:outputStylesheet library="css" name="company/company.css"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search.css"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search_desktop.css" media="screen and (min-width:1025px) and (max-width:1600px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search_desktop_wide.css" media="screen and (min-width : 1601px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search_tablet.css" media="screen and (min-device-width : 768px) and (max-device-width : 1024px), screen and (max-width:1024px)"></h:outputStylesheet>
                <h:outputStylesheet library="css" name="company/search/search_smartphone.css" media="screen and (min-device-width : 320px) and (max-device-width : 767px), screen and (max-width:767px)"></h:outputStylesheet>

                <h:form id="searchListForm" styleClass="fullWidthContainer">
                    <p:growl id="searchListGrowl"></p:growl>

                    <p:dialog id="candidateDetailDialog" widgetVar="candidateDetailDialog" resizable="false" modal="true" position="top">
                        <ccDetail:CandidateDetailPanel id="candidateDetailPanel"
                                                       bean="#{newSearchListBean}"
                                                       candidate="#{newSearchListBean.selectedCandidate}"                   
                                                       >
                        </ccDetail:CandidateDetailPanel>
                        <p:commandButton async="true" styleClass="redBackgroundStrong inlineBlock" global="false" oncomplete="candidateDetailDialog.hide();"  value="#{messages.Report}" actionListener="#{newSearchListBean.reportSelectedCandidate()}" process="@this"></p:commandButton>
                        <p:commandButton async="true" styleClass="blueBackgroundStrong inlineBlock" action="#{bagBean.addCandidate(newSearchListBean.selectedCandidate)}" style="margin-left: 5%!important;" global="false" oncomplete="candidateDetailDialog.hide();" value="#{messages.Select}" update=":bagPanel" process="@this"></p:commandButton>                    
                    </p:dialog>

                    <p:panel styleClass="fullPanelMargin lightGrayBackgroundTitle fullWidthPanelTitlePadding noMargin noPaddingTitle  lightGrayBorder" header="#{messages.Searchs}">
                        <p:commandButton async="true" ajax="false" styleClass="redBackgroundStrong block" value="#{messages.Search}" actionListener="#{newSearchListBean.prepareNewSearch()}" action="#{newSearchListBean.redirectToViewEntity()}"></p:commandButton>
                        <p:panel id="searchPanel" styleClass="noBorder noPadding noMargin" >
                            <ui:repeat id="searchRepeater" varStatus="step" var="search" value="#{newSearchListBean.entityList}">
                                <p:panel styleClass="#{step.index%3==2 ? 'noMarginRight' : ''} noPadding noBorder searchRepeated inlineBlock">
                                    <p:panel styleClass="strongGraySlimBorder noPadding noMargin">
                                        <div class="strongGraySectionBackground">
                                            <div class="internalSearchLeftColumn colorWhite inlineBlock verticalAlignTop">
                                                <h:outputText value="#{messages.Name}" />
                                            </div>
                                            <div class=" internalSearchRightColumn inlineBlock verticalAlignTop strongGraySlimBorderTop">
                                                <h:outputText styleClass="block" value="#{search.description}"/>
                                            </div>
                                            <div class="internalSearchLeftColumn colorWhite inlineBlock verticalAlignTop">
                                                <h:outputText value="#{messages.ValidCandidates}" />
                                            </div>
                                            <div class=" internalSearchRightColumn inlineBlock verticalAlignTop ">
                                                <h:outputText id="valid" styleClass="block" value="#{search.validCandidates==null? messages.Loading: search.validCandidates}"/>
                                            </div>
                                            <div class="internalSearchLeftColumn colorWhite inlineBlock verticalAlignTop">
                                                <h:outputText value="#{messages.NewCandidates}" />
                                            </div>
                                            <div class=" internalSearchRightColumn inlineBlock verticalAlignTop ">
                                                <h:outputText id="new" styleClass="block" value="#{search.candidatesSinceLastView==null?messages.Loading :search.candidatesSinceLastView}"/>
                                            </div>
                                            <div class="internalSearchLeftColumn colorWhite inlineBlock verticalAlignTop">
                                                <h:outputText value="#{messages.SearchFolder}" />
                                            </div>
                                            <div class=" internalSearchRightColumn inlineBlock verticalAlignTop strongGraySlimBorderBottom">
                                                <h:outputText styleClass="block" value="#{search.folder.description}" rendered="#{search.folder!=null}"/>
                                                <h:outputText styleClass="block" value="#{messages.None}" rendered="#{search.folder==null}"/>
                                            </div>
                                        </div>
                                    </p:panel>
                                    <p:panel id="faces" styleClass="noBorder noMargin noPadding">
                                        <ui:repeat rendered="#{search.previewCandidateList!=null and !search.previewCandidateList.isEmpty()}" var="candidate" value="#{search.previewCandidateList}"  >
                                            <p:commandLink async="true" actionListener="#{newSearchListBean.setSelectedSearchAndCandidate(search, candidate)}" process="@this" update=":searchListForm:candidateDetailPanel :searchListForm:candidateDetailDialog" oncomplete="PF('candidateDetailDialog').show();" >
                                                <h:graphicImage rendered="#{candidate.bustBlackWhite==null}" styleClass="searchImage" library="images" name="bustnotavailable.jpg"></h:graphicImage>                            
                                                <h:graphicImage rendered="#{candidate.bustBlackWhite!=null}" styleClass="searchImage" value="/candidateFiles/#{candidate.idCandidate.toString()}/images/#{candidate.bustBlackWhite}"></h:graphicImage>  
                                            </p:commandLink>
                                        </ui:repeat>
                                        <h:outputText rendered="#{search.previewCandidateList==null or search.previewCandidateList.isEmpty()}" styleClass="marginLeft20 " value="#{messages.Loading}"/>
                                    </p:panel>
                                    <p:commandButton async="true" style="margin-right: 0.5em" styleClass="redBackgroundStrong" value="Ver Candidatos" actionListener="#{newSearchListBean.viewSearch(search)}" action="#{newSearchListBean.redirectToViewEntity()}" process="@this"></p:commandButton>
                                    <p:commandButton async="true" style="margin-right: 0.5em" styleClass="redBackgroundStrong marginBottom05em" actionListener="#{newSearchListBean.setChosenEntity(search)}" value="Editar" process="@this"></p:commandButton>
                                    <p:remoteCommand actionListener="#{newSearchListBean.getSearchFields(search)}" autoRun="true" rendered="#{search.validCandidates==null}" update="@parent" />
                                </p:panel>
                            </ui:repeat>
                        </p:panel>
                    </p:panel>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
